﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MSSClient.Model
{
    //发票信息Model
    [Serializable]
    public class InvoiceModel
    {
        public String invoiceType = "";   //发票类型 0104普通发票 0110普通电子发票 0101专用发票
        public String invoiceCode = "";   //发票代码
        public String invoiceNum = "";    //发票号码
        public String invoiceDate = "";   //开票日期
        public String amount = "0.0";     //不含税金额
        public String totalAmount = "0.0";//含税金额
        public String checkCode = "";     //校验码
        public String sellerName = "";    //付款方
        public String buyerName = "";     //收款方
        public String invoiceContent = "";//发票内容

        public static InvoiceModel LoadModelInfo(String infoStr)
        {
            String[] info = infoStr.Split(',');
            InvoiceModel invoiceModel = new InvoiceModel();
            invoiceModel.invoiceType = info[0]+info[1];
            invoiceModel.invoiceCode = info[2];
            invoiceModel.invoiceNum = info[3];
            invoiceModel.amount = info[4];
            if (info[5]!="")
            {
                String date = info[5];
                String year = date.Substring(0, 4);
                String mouth = date.Substring(4, 2);
                String day = date.Substring(6, 2);
                invoiceModel.invoiceDate = year + "-" + mouth + "-" + day;
            }
            invoiceModel.checkCode = info[6];
            return invoiceModel;
        }

        public InvoiceModel()
        {
            this.amount = "";
            this.buyerName = "";
            this.invoiceCode = "";
            this.invoiceContent = "";
            this.invoiceDate = "";
            this.invoiceNum = "";
            this.invoiceType = "";
            this.sellerName = "";
            this.totalAmount = "";
            this.checkCode = "";
        }

        public override string ToString()
        {
            String invoiceModelStr = "invoiceCode:" + this.invoiceCode + ", invoiceContent:" + this.invoiceContent + ", invoiceDate:" + this.invoiceDate + ", invoiceNum" + this.invoiceNum + ", invoiceType:" + this.invoiceType + ", sellerName " +
                this.sellerName+ ", amount:" + this.amount+ ", buyerName:" + this.buyerName+ ", checkCode:" + this.checkCode+ ", totalAmount:" + this.totalAmount;
            return invoiceModelStr;
        }
    }
}
